package com.dev.dream.exochatlockscreen;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.dev.dream.libs.checknetwork.CheckNetword;
import com.startapp.android.publish.StartAppAd;
import com.startapp.android.publish.StartAppSDK;

public class SplashActivity extends Activity {

	int time;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);

		setContentView(R.layout.activity_splash);
		StartAppSDK.init(this, "111076217 ", "210808285", true);
		StartAppAd.showSplash(this, savedInstanceState);
		ImageView i = (ImageView) findViewById(R.id.iSplash);
		i.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getApplicationContext(),
						MainActivity.class);
				startActivity(i);

				handler.removeCallbacks(runnable);
				finish();
			}
		});

		if (CheckNetword.checkInternetConnection(this)) {
			handler.postDelayed(runnable, 11000);
		} else {
			handler.postDelayed(runnable, 6000);
		}

	}

	Handler handler = new Handler();
	Runnable runnable = new Runnable() {

		@Override
		public void run() {
			// TODO Auto-generated method stub

			handler.removeCallbacks(runnable);
			Intent i = new Intent(getApplicationContext(), MainActivity.class);
			startActivity(i);

			finish();

		}
	};

	protected void onResume() {
		super.onResume();

	};

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub

	}
}
